<template>
  <div class="about">
    <h1>This is an about page</h1>
    <ul class="con">
      <child
        v-for="(item, index) in list"
        :key="item.id"
        :item="item"
        :index="index"
        @click.native="gotodetail(item.id)"
        @remove="remove"
      />
    </ul>
  </div>
</template>
<script>
import child from "../components/Child.vue";
export default {
  data() {
    return {
      list: [],
    };
  },
  mounted() {
    this.$axios.get("https://api.it120.cc/small4/cms/news/list").then((res) => {
      console.log(res);
      this.list = res.data.data;
    });
  },
  components: {
    child,
  },
  methods: {
    gotodetail(id) {
      this.$router.push({ path: "/detail", query: { id: id } });
    },
    remove(index) {
      this.list.splice(index, 1);
    },
  },
};
</script>
<style lang="scss">
.con {
  display: flex;
  flex-wrap: wrap;
  li {
    width: 50%;
    img {
      width: 80%;
    }
  }
}
</style>
